hallcurrent5 2.2.0
hallcurrent5


Hall Current 5 Click

Hall Current 5 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : MikroE Team
  • Date : Dec 2019.
  • Type : ADC type

Software Support

Example Description

The demo application reads ADC value and current value.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.HallCurrent5

Example Key Functions

Application Init

Initialization device and ADC Init.

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
HALLCURRENT5_MAP_MIKROBUS( cfg, MIKROBUS_1 );
hallcurrent5_init( &hallcurrent5, &cfg );
// CLICK INIT
hallcurrent5_set_adc_resolution( &hallcurrent5, HALLCURRENT5_ADC_RESOLUTION_12bit );
hallcurrent5_set_init_voltage( &hallcurrent5, 316 );
Delay_100ms();
}
#define HALLCURRENT5_MAP_MIKROBUS(cfg, mikrobus)
Definition hallcurrent5.h:65
void hallcurrent5_set_init_voltage(hallcurrent5_t *ctx, uint16_t voltage)
Get ADC current value function.
void application_init(void)
Definition main.c:37

Application Task

Reads current value in mA and this data logs to USBUART every 500ms.

void application_task ( void )
{
int16_t adc_value;
uint32_t sum_adc = 0;
uint8_t cnt;
float current;
// Task implementation.
tmp = hallcurrent5_generic_read( &hallcurrent5 );
log_printf( &logger, "** ADC value : [DEC]- %d, [HEX]- 0x%x \r\n", tmp, tmp );
Delay_ms ( 1000 );
sum_adc = 0;
for(cnt = 0; cnt < 20; cnt++)
{
sum_adc += hallcurrent5_generic_read( &hallcurrent5 );
}
adc_value = ( sum_adc / 20 );
current = hallcurrent5_get_current( &hallcurrent5, adc_value/1.8 );
if ( current < 0 )
{
current = 0;
}
log_printf( &logger, " ADC value: %d \r\n", adc_value);
log_printf( &logger, " Current : \r\n", adc_value);
Delay_ms ( 500 );
}
hallcurrent5_data_t hallcurrent5_generic_read(hallcurrent5_t *ctx)
Generic read function.
uint16_t hallcurrent5_data_t
Analog data type.
Definition hallcurrent5.h:91
void application_task(void)
Definition main.c:66

Note

Before the start of the program you have to set the starting voltage on AN pin. First, measure the voltage in mV on AN pin, when electronic load isn't > connected to the Click board, and pass that value as an input parameter of the voltage initialization function.

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.